/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.bld.util.seguranca;

import br.com.bld.util.facade.BLDDataErro;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 *
 * @author Pedro
 */
public class BLDCriptografia implements BLDDataErro {

    public static String getMD5(String texto) throws NoSuchAlgorithmException {
        String resposta = null;
        
        if (texto == null || texto.equals("")) {
            throw new IllegalArgumentException(String.format(PARM_NAO_INFORMADO, "Texto"));
        }
        
        MessageDigest md = MessageDigest.getInstance("MD5");
        BigInteger hash = new BigInteger(1, md.digest(texto.getBytes()));
        
        resposta = hash.toString(16);
        
        return resposta;
    }
}
